from sqlalchemy.orm import Session
from typing import List, Optional
from app.models.iaro_coop_admin.sponsor import SponsorContact
class SponsorContactRepo:
    def __init__(self, db: Session):
        self.db = db

    def get_by_sponsor_id(
        self,
        sponsor_id: int,
        kc: Optional[bool] = None,
        inv: Optional[bool] = None,
    ) -> List[SponsorContact]:

        q = self.db.query(SponsorContact).filter(
            SponsorContact.sponsor_id == sponsor_id
        )
        if kc:
            q = q.filter(SponsorContact.kc == "Y")
        if inv:
            q = q.filter(SponsorContact.inv == "Y")
        return q.all()